package ca.badenhorst.ourtrition.model;


import java.util.ArrayList;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: wade
 * Date: 17/02/14
 * Time: 11:03 AM
 * To change this template use File | Settings | File Templates.
 */
public class FoodDescription {
    public static final String NDB_NO = "ndb_no";

    private String ndbNo;
    private String foodGroupCd;
    private String foodGroupDesc;
    private String shortDesc;
    private String longDesc;
    private String facet;
    private Nutritions nutritions = null; // base nutritions are normalized for 100 grams of the particular food
    private List<SampleSize> sampleSizes = null;

    public String getFoodGroupDesc() {
        return foodGroupDesc;
    }

    public void setFoodGroupDesc(String foodGroupDesc) {
        this.foodGroupDesc = foodGroupDesc;
    }

    public String getNdbNo() {
        return ndbNo;
    }

    public void setNdbNo(String ndbNo) {
        this.ndbNo = ndbNo;
    }

    public String getFoodGroupCd() {
        return foodGroupCd;
    }

    public void setFoodGroupCd(String foodGroupCd) {
        this.foodGroupCd = foodGroupCd;
    }

    public String getShortDesc() {
        return shortDesc;
    }

    public void setShortDesc(String shortDesc) {
        this.shortDesc = shortDesc;
    }

    public String getLongDesc() {
        return longDesc;
    }

    public void setLongDesc(String longDesc) {
        this.longDesc = longDesc;
        // grab stuff before first comma and assume that is the 'sub-group'
        int i = longDesc.indexOf(",");
        if (i > 0) {
            this.setFacet(longDesc.substring(0, i).trim());
        } else {
            this.setFacet(longDesc.trim());
        }

    }

    public String getFacet() {
        return facet;
    }

    public void setFacet(String facet) {
        this.facet = facet;
    }

    public Nutritions getNutritions() {
        return nutritions;
    }

    public void setNutritions(Nutritions nutritions) {
        this.nutritions = nutritions;
    }

    public List<SampleSize> getSampleSizes() {
        return sampleSizes;
    }


    public void setSampleSizes(List<SampleSize> sampleSizes) {
        this.sampleSizes = sampleSizes;
    }

    @Override
    public String toString() {
        return "FoodDescription{" +
                "ndbNo='" + ndbNo + '\'' +
                ", foodGroupCd='" + foodGroupCd + '\'' +
                ", shortDesc='" + shortDesc + '\'' +
                ", longDesc='" + longDesc + '\'' +
                ", nutritions=" + nutritions +
                ", sampleSizes=" + sampleSizes +
                '}';
    }

    public List<SampleSize> getSampleSizesWithDefault() {
        List<SampleSize> results = new ArrayList<SampleSize>();
        results.add(SampleSize.getDefault());
        results.addAll(getSampleSizes());
        return results;
    }
}
